package com.heima.kafka.listener;

import com.alibaba.fastjson.JSON;
import com.heima.kafka.pojo.User;
import org.apache.kafka.clients.consumer.Consumer;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

@Component
public class HelloListener {

    @KafkaListener(topics = "order")
    public void onMessage(String msg){
        System.out.println(msg);
    }

    @KafkaListener(topics = "obj")
    public void onMessageObj(String msg){
        System.out.println(msg);

        User user = JSON.parseObject(msg, User.class);
        System.out.println(user);
    }
}
